import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.util.ArrayList;

public class mainFrame extends JFrame {


    public void CreateFrame() throws Exception {
        String title = "哈哈恭喜你中毒了";
        JFrame jf = new JFrame(title);
        jf.setLayout(null);
        Container container = jf.getContentPane();
        String sucessInfo = LogicHandle.logicEncry();
        JLabel jl2 = new JLabel(sucessInfo);
        jl2.setBounds(10,10,50,50);
        System.out.println(sucessInfo);
        jl2.setBounds(150,30,500,30);
         JLabel jl = new JLabel("滚动框中的数字相加之和就是解毒的密钥,注意这些是随机的，程序每运行一次结果都不同");
         jl.setBounds(150,230,700,30);
         JLabel jl3 = new JLabel("若解密成功则会自动退出java程序");
        jl3.setBounds(150,280,700,30);
         container.add(jl3);
         container.add(jl);



        //随机生成100个数相加结果
        SumOfRandomNumbers nums = new SumOfRandomNumbers();

        ArrayList<Integer> numList =nums.numList();
        // 将集合中的数字转换为字符串数组，以便在JList中显示
        String[] numbers = new String[numList.size()];
        for(int i=0; i<numList.size(); i++) {
            numbers[i] = String.valueOf(numList.get(i));
        }
        // 创建一个JList，并将数字字符串数组传递给它
        JList<String> list = new JList<>(numbers);

        JScrollPane jScrollPane = new JScrollPane(list);
        jScrollPane.setBounds(0,100,1000,500);
        container.add(jScrollPane,BorderLayout.CENTER);


        JButton button = new JButton("解毒");
        button.setBackground(Color.blue);
        button.setSize(80,50);

        button.addActionListener(new ButtonAction());
        container.add(button,BorderLayout.PAGE_END);
        container.add(jl2, BorderLayout.NORTH);
        container.setBackground(Color.white);
        jf.setVisible(true);  //使窗口可视
        jf.setSize(1000, 800);
        //设置窗口关闭方式
        jf.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);





    }

//    public static void main(String[] args) throws Exception {
//
//    }
}